<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const xhr = new XMLHttpRequest();
      xhr.open("GET", "http://127.0.0.1:3000/users");

      xhr.responseType = "json";
      xhr.onload = function () {
        /*
        cache-control: no-cache
        content-length: 380
        content-type: application/json
        expires: -1
        pragma: no-cache
        */
        const str = xhr.getAllResponseHeaders();
        const arr = str
          .split("\r\n")
          .slice(0, -1)
          .map((el) => el.split(": "));
        const obj = Object.fromEntries(arr);
        console.log(obj);
      };
      // 发送请求
      xhr.send();
    </script>
  </body>
</html>
